/**
 * 
 */
package ar.com.sebasoft.prestalibro.util.impl;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import android.util.Log;
import ar.com.sebasoft.prestalibro.util.EncryptionStrategy;
import ar.com.sebasoft.prestalibro.util.SystemHelper;

/**
 * @author SebaSOFT
 * 
 */
public class EncryptionSHA1Strategy implements EncryptionStrategy {

	public static int NO_OPTIONS = 0;

	@Override
	public String encryptKey(String clave) {
		String res = "";
		MessageDigest digest = null;
		try {
			digest = MessageDigest.getInstance("SHA-1");
		} catch (NoSuchAlgorithmException e) {
			Log.e(SystemHelper.APP_TAG, "Error when SHA1 hasing the password", e);
		}
		digest.reset();
		byte[] data = digest.digest(clave.getBytes());
		res = String.format("%0" + (data.length * 2) + "X", new BigInteger(1, data));
		return res;
	}

}
